home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7202 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1009 b 

  1. Path: free1-slip207.tele.queensu.ca!user
  2. From: 3gl21@qlink.queensu.ca (Gregory Lo)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Why Do Return Values Sometimes Have '&' Appended?
  5. Date: Wed, 21 Feb 1996 20:48:55 -0608
  6. Organization: Queen's University
  7. Distribution: world
  8. Message-ID: <3gl21-2102962048550001@free1-slip207.tele.queensu.ca>
  9. References: <4ggciv$iq1@alcor.usc.edu>
  10. Reply-To: 3gl21@qlink.queensua.c
  11. NNTP-Posting-Host: free1-slip207.tele.queensu.ca
  12. X-Newsreader: Yet Another NewsWatcher 2.2.0b4
  13.  
  14. In article <4ggciv$iq1@alcor.usc.edu>, wawda@alcor.usc.edu (Abu Wawda) wrote:
  15.  
  16. > I have seen code where some of the functions are returned with the
  17. > reference operator (&) attached to the end. Here is an example:
  18. [snip]
  19. > I understand why you the function parameter uses the & operator since
  20. > you want to pass the class by reference, but why is it used in the
  21. > return value? Thank you,
  22.  
  23. Simply enough, you want to return a *reference* to an object rather than a
  24. new object constructed on the stack.
  25.  
  26. Greg Lo
  27.